<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Document</title>
    </head>
    <body>
        <table border="1">
            <tbody></tbody>
        </table>
        <script>
            function ajax_get(cb) {
                const xhr = new XMLHttpRequest();
                xhr.open("GET", `https://api.gugudata.com/news/joke/demo`);
                xhr.send();
                xhr.onload = function () {
                    if (xhr.status === 200) {
                        let res = JSON.parse(xhr.responseText).Data;
                        cb(res);
                    }
                };
            }
            function renderDom(data) {
                const tbody = document.querySelector("tbody");
                let str = `<tr><td>标题</td><td>内容</td></tr>`;
                data.forEach((el) => {
                    str += `
                    <tr><td>${el.Title}</td><td>${el.Content}</td></tr>
                    `;
                });
                tbody.innerHTML = str;
            }
            ajax_get(renderDom);
        </script>
    </body>
</html>
